package com.fc.happyteam.entity;

public enum SMSModule {
    register(1407873, "注册", 1),
    resetPwd(1407873, "重置密码", 2),
    recharge(1871222, "充值", 3),
    verifyCode(1407873, "验证码", 4),
    other(0, "其他", 99);
    private int tplId;
    private String operation;
    private int dbValue;

    SMSModule(final int tplId, final String operation, final int dbValue){
        this.tplId = tplId;
        this.operation = operation;
        this.dbValue = dbValue;
    }

    public int getTplId() {
        return tplId;
    }

    public String getOperation() {
        return operation;
    }
    public int getDbValue() {
        return dbValue;
    }

    public static SMSModule fromString(final String value){
        final SMSModule[]  modules = SMSModule.values();
        for(final SMSModule module : modules){
            if(module.toString().equals(value)){
                return module;
            }
        }
        return other;
    }

    public static SMSModule fromInt(int value){
        final SMSModule[]  modules = SMSModule.values();
        for(final SMSModule module : modules){
            if(module.getDbValue() == value){
                return module;
            }
        }
        return other;
    }
}
